package Sequence::Infinite::Concatenate;
use base 'Sequence::Infinite';

sub new {
    my $infinite_sequence = pop;
    my( $class, @listrefss ) = @_;
    my $this = $class->SUPER::new();
    
    $this->{sequence} = $infinite_sequence;
    $this->{list} = [ map { @{$_} } @listrefss ];
    $this->{curr} = 0;
    $this;
}

sub increment {
    my( $this ) = @_;
    my $val;
    
    if( $this->{curr} >= @{ $this->{list} } ) {
        $val = $this->{sequence}->increment;
    } else {
        $val = $this->{list}->[ $this->{curr} ];
        $this->{curr}++;
    }

    $val;
}

1;
